<template>
  <!-- 上传厂家证照的表格modal -->
  <div>
    <basic-modal 
        :modalOpt="modal" 
        :buttonText="['','关闭']"
        @onMakeSure="onPush"
        @closeModal="closeModal" 
        :footer="footer" 
        >
      <template #cusBtn>
      </template>
      <template>
        <batch-operat-btn v-if="editable" :isView="false" :addData="true" @onAddData="onAddData">
          <template #cusBtn> </template>
        </batch-operat-btn>
        <a-list-info :infoDatas="infoDatas" />
      </template>
    </basic-modal>
  </div>
</template>

<script>
import basicModal from '@/views/app/biz/common/basicModal'
import aListTable from '@/views/app/biz/common/aListTable'
import aListInfo from '@/views/app/biz/common/aListInfo'
import batchOperatBtn from '@/views/app/biz/common/batchOperatBtn'

import {
  getInfoByPid,
  auditInfo
} from './settlement' 

export default {
  components: {
    basicModal,
    aListTable,
    batchOperatBtn,
    aListInfo
  },
  data() {
    return {
      footer:undefined,
      editable:false,
      loading: false,
      modal: {
        modalVisible: false,
        modalTitle: '查看详情',
        modalWidth: '90vw',
      },
      infoDatas:[
        { title: '采购单位OrgPid', id: 'orgPid', value: '' },
        { title: '采购单位名称', id: 'customerName', value: '' },
        { title: '结算单号', id: 'settlementNo', value: '' },
        { title: '结算单生成时间', id: 'settlementCreatTime', value: '' },
        { title: '结算单确认时间', id: 'settlementCfmTime', value: '' },
        { title: '结算单完成时间', id: 'settlementFinTime', value: '' },
        { title: '采购单位备注', id: 'remarker', value: '' },
        { title: '供应商orgPid', id: 'supplierOrgPid', value: '' },
        { title: '供应商名称', id: 'supplierName', value: '' },
        { title: '发票类型', id: 'invoiceType', value: '' },
        { title: '开票信息', id: 'invoiceInfo', value: '' },
        { title: '发票状态', id: 'invoiceState', value: '' },
        { title: '结算状态', id: 'settlementState', value: '' }
      ],
      listdata: [],
      listKey: 0,
      pid: '',
      zzPid:'',
      sysSeq: 0,
      loadings: false,
    }
  },
  computed: {},
  mounted() {},
  methods: {
    // // 弹出模态框
    showModal(val,record) {
      this.pid = val.pid
      this.record=record
      this.modal.modalVisible = true
      this.modal.modalTitle = '查看详情'
      this.getSBypid(val)
      // this.getZZImgBypid(val2)
      
    },
    // 关闭模态详细框
    closeModal() {
      this.modal.modalVisible = false
      this.$emit('close')
    },
    closeModal2() {
      this.modal.modalVisible = false
      this.$emit('ok')
    },
    //
    onAddData() {
      this.$refs.addSellerLicChildModal.addModal(this.pid)
    },

    // 审核
    onPush() {
      this.showConfirm(this.record)
    },
    showConfirm(val) {
      const that = this;
      let subData = {
        sysSeq: val.sysSeq,
        pid: val.pid,
        zhuangTai:'4'
      }
      this.$confirm({
        title: '是否通过审核？',
        content: '审核成功后请提请到商品管理查看！',
        onOk() {
          return new Promise((resolve, reject) => {
            resolve(auditInfo(val))
          }).then((res)=>{
            if (res && res.code && res.code === 'C1' && res.data) {
              that.$message.success({ content: '提交成功', duration: 2 })
              that.handleModalSaveOk()
            } else {
              that.$message.error({ content:res.code +'：'+res.message, duration: 2 })
            }
          })
          .catch(() =>{
            that.$message.error({ content:"请求出错", duration: 2 })
          });
        },
        onCancel() {},
      });
    },
    // 得到初始化信息
    async getSBypid(val) {
      let res = await getInfoByPid(val)
      if (res && res.code && res.code === 'C1') {
        this.sysSeq = res.data.sysSeq
        for (const key in res.data) {
            for (const item of this.infoDatas) {
                if(key==item.id){
                    item.value=res.data[key]
                }
            }
        }
      }
    },
    // 得到初始化证照图片信息
    // async getZZImgBypid(val2) {
    //   this.loading=true
    //   let pa = {
    //     zhengZhaoPid: val2,
    //   }
    //   let res = await getZZImgByzzpid(pa)
    //   if (res && res.code && res.code === 'C1' && res.data) {
    //     this.listdata = res.data
    //     this.loading=false
    //   }
    //   console.log(res)
    // },
  },
}
</script>

<style>
.recordBox {
  width: 100%;
  min-height: 80px;
}
</style>